package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC929 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int numUniqueEmails(String[] emails) {
            Set<String> eSet = new HashSet<>();
            for (String email : emails) {
                String[] split = email.split("@");
                String realSend = split[0].substring(0, (split[0].indexOf("+") == -1 ? split[0].length() : split[0].indexOf("+"))).replaceAll("\\.", "") + "@" + split[1];
                eSet.add(realSend);
            }
            return eSet.size();
        }
    }

    public void run() {
        System.out.println(new Solution().numUniqueEmails(new String[]{"test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com", "testemail+david@lee.tcode.com"}));
        System.out.println(new Solution().numUniqueEmails(new String[]{"a@leetcode.com", "b@leetcode.com", "c@leetcode.com"}));

    }

    public static void main(String[] args) throws Exception {
        LC929 an = new LC929();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
